﻿<UserControl x:Class="TrailMapManager.Modules.Maps.View.MapsModuleMainView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:bing="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="500">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/ModernControls;component/Style.xaml"/>
                <ResourceDictionary>
                    <Style x:Key="mapListItemStyle" TargetType="{x:Type ListBoxItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                    <Grid>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Selected">
                                                    <Storyboard>
                                                        <ColorAnimation Storyboard.TargetName="bgBrush"
                                                            Storyboard.TargetProperty="Color"
                                                            To="{StaticResource AppBaseColor}"
                                                            Duration="00:00:00.2"/>
                                                        <ColorAnimation Storyboard.TargetName="textBrush"
                                                            Storyboard.TargetProperty="Color"
                                                            To="White"
                                                            Duration="00:00:00.2"/>
                                                    </Storyboard>
                                                </VisualState>

                                                <VisualState x:Name="Normal">
                                                    <Storyboard>
                                                        <ColorAnimation Storyboard.TargetName="bgBrush"
                                                            Storyboard.TargetProperty="Color"
                                                            To="White"
                                                            Duration="00:00:00.2"/>
                                                        <ColorAnimation Storyboard.TargetName="textBrush"
                                                            Storyboard.TargetProperty="Color"
                                                            To="Black"
                                                            Duration="00:00:00.2"/>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <ColorAnimation Storyboard.TargetName="bgBrush"
                                                            Storyboard.TargetProperty="Color"
                                                            To="{StaticResource AppBaseLightestColor}"
                                                            Duration="00:00:00.2"/>
                                                        <ColorAnimation Storyboard.TargetName="textBrush"
                                                            Storyboard.TargetProperty="Color"
                                                            To="Black"
                                                            Duration="00:00:00.2"/>
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Grid.Background>
                                            <SolidColorBrush x:Name="bgBrush" Color="{StaticResource AppBaseLightestColor}"/>
                                        </Grid.Background>
                                        <TextBlock Text="{Binding Description}"
                                                   FontSize="20"
                                                   FontFamily="Segoe UI Light">
                                            <TextBlock.Foreground>
                                                <SolidColorBrush Color="White" x:Name="textBrush"/>
                                            </TextBlock.Foreground>
                                        </TextBlock>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid Background="White">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.5*" MinWidth="330"/>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <!--MapFiles-->
        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="50"/>
            </Grid.RowDefinitions>
            <ListBox ItemsSource="{Binding CommMan.Maps}"  
                      SelectedItem="{Binding SelectedMap, Mode=TwoWay}"
                      ScrollViewer.CanContentScroll="False"
                      BorderBrush="Transparent"
                      ItemContainerStyle="{StaticResource mapListItemStyle}">
                <ListBox.InputBindings>
                    <KeyBinding Key="Delete" Command="{Binding DeleteMapCommand}"/>
                </ListBox.InputBindings>
            </ListBox>

            <!--Controls-->
            <Grid Grid.Row="1"
                  Background="{StaticResource AppAlter1LightestBrush}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Button Content="add map" Command="{Binding AddMapCommand}" Grid.Column="0" FontSize="16" Width="100"/>
                <Button Content="delete map" Command="{Binding DeleteMapCommand}" Grid.Column="1" FontSize="16" Width="100"/>
                <Button Content="delete all" Command="{Binding DeleteAllMapCommand}" Grid.Column="2" FontSize="16" Width="100"/>
            </Grid>
        </Grid>

        <!--BingMapView-->
        <Grid Grid.Column="1">
            <bing:Map CredentialsProvider="Aoa1v3rq4CwdNXLnP7PaD2mQB7ZeX_RRVhgh57nJHW-TRicViXcasM8XLenxnVKK"
                      Center="{Binding MapCenter, Mode=TwoWay}">
                <bing:MapPolygon Locations="{Binding MapBoundaryLocation}" Stroke="Black" StrokeThickness="2" Fill="#8863c630"/>
            </bing:Map>
        </Grid>
    </Grid>
</UserControl>
